﻿@using Gx.Model.Entity;
@using Gx.Model.Enums;
@{
    ViewBag.Title = "添加客户预付款";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}
<link href="~/Content/css/custome.css" rel="stylesheet" />
<div title="添加客户预付款" style="width:auto; height:auto; padding-left:5px; font-size:14px;  ">
    <div class="ftitle">
        <a href="javascript:" class="easyui-linkbutton" iconCls="icon-ok" style="height:32px" onclick="saveData()">保存</a>
    </div>
    <form id="fm" method="post" novalidate>
        <div class="ftitle">基础信息</div>
        <div class="fitem1">
            <label>
                单据编号:
            </label>
            <input class="easyui-textbox" readonly="readonly" value="系统自动生成" style="width: 173px; height: 30px;">
            <label>
                客户:
            </label>
            <select class="easyui-combogrid" style="width: 173px; height: 30px;" name="CustomerId" id="CustomerId"></select>
            <label>
                客户名称:
            </label>
            <input name="CustomerName" id="CustomerName" value="@Model.CustomerName" class="easyui-textbox" style="width: 173px; height: 30px;" readonly="readonly" />
        </div>
        <div class="fitem1">
            <label>
                时间:
            </label>
            <input class="easyui-datebox" name="PrePayTime" id="PrePayTime" value="@Model.PrePayTime" style="width: 173px; height: 30px; " data-options="required:true">
            <label>
                预付金额:
            </label>
            <input name="PreAmount" id="PreAmount" value="@Model.PreAmount" class="easyui-numberbox" data-options="required: true,precision:'2'" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem1">
            <label>
                备注:
            </label>
            <textarea rows="4" cols="4" style="width: 845px; height: 90px; vertical-align: top" name="Remark" id="Remark" autocomplete="off" placeholder="200字以内"></textarea>
        </div>
        @Html.Partial("~/Views/Shared/_CreateUserAndModifyUser.cshtml")
    </form>
    <div id="customerselecttoolbar2">
        <input id="SelectCustomerText2" class="easyui-textbox " style="width: 173px; height: 30px;" />
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="querycustomer2()">查询</a>
    </div>
</div>
<script src="~/Js/Global.js"></script>
<script type="text/javascript">

    $(function () {
        InitCustomer();
    });

    var domId = 1;
    function addDom() {
        $.post("/Finance/_AddLKCustomerPrePayment", { domId: domId }, function (html) {
            $.messager.progress('close');
            $(".gridtable").append(html);
            $.parser.parse($("#" + domId));
            InitCostTypesCombogrid(domId);
            domId = Number(domId) + 1;
        });
    }

    function delDom(domId) {
        $("#" + domId).remove();
    }


    function querycustomer2() {
        $("#CustomerId").combogrid("grid").datagrid("reload", { "CustomerName": $("#SelectCustomerText2").val() });
    }


    function saveData() {
        var validate = $("#fm").form("validate")
        if (!validate) {
            return;
        }
        var data = {
            "PrePayTime": $("#PrePayTime").datebox('getValue'),
            "CustomerId": $("#CustomerId").combobox('getValue'),//$("#hidCustomerId").val(),
            "CustomerNo": $("#CustomerId").combobox('getText'),
            "CustomerName": $("#CustomerName").textbox('getValue'),
            "PreAmount": $("#PreAmount").numberbox('getValue'),
            "Remark": $("#Remark").val()
        };
        $.messager.progress({
            title: '请稍后',
            msg: '数据保存中...',
        });
        window.setTimeout(function () {
            $.ajax({
                url: '/Finance/AddLKCustomerPrePayment',
                type: "post",
                data: JSON.stringify({ LKCustomerPrePayment: data }),
                contentType: 'application/json; charset=utf-8',
                success: function (json) {
                    $.messager.progress('close');
                    Helper.Show(json.Msg);
                    if (json.Success) {
                        setTimeout(function () { window.location.href = "/Finance/LKCustomerPrePaymentList"; }, 2000);
                    }
                }
            });
        }, 2000);
    }
</script>





